        var receivableStore = new Ext.data.JsonStore({
			url: '/weihe/getList_receivable',
			root: 'datas',
			fields : [{
						name:'ReceivableId',mapping:'id'
					},{
     				   name:'ReceivableDate', mapping:'date',type : 'date', dateFormat:"Y-m-d"
      			  	},{
						name:'ReceivableType',mapping:'type'
					},{
						name:'ReceivableName',mapping:'name'
					},{
						name:'ReceivableRecei',mapping:'recei'
				    },{
				    	name:'ReceivableContent',mapping:'content'
				    },{
				    	name:'ReceivableRbalance',mapping:'rbalance'
				    },{
				    	name:'ReceivableDbalance',mapping:'dbalance'
				    },{
				    	name:'ReceivableClerk',mapping:'clerk'
				    },{
				    	name:'ReceivableRemark',mapping:'remark'
				    },{
				    	name:'ReceivableState',mapping:'state'
				    }],
				    baseParams : {'receivable.type': 'local'},
						listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_receivable',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    	

receivables = function(){
	var tmp;
	
  return{
     
	  receivableGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 15,
			store : receivableStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		});

	

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		 
	   var receivableGrid = new Ext.grid.GridPanel({
		   id:'receivableGrid',
		   title : '国内(人民币)',
		   region : 'center',
		   minColumnWidth : 50,
		   tbar:["-",{
	   						text:"输入查询条件",
								handler:function(){
										receivables.infoWin().show();
								}
	   					},"-",{
	   						text:"查看全部",
								handler:function(){
									Ext.getCmp("receivableGrid").getStore().baseParams = {'flag': false,'receivable.type': 'local'};
									Ext.getCmp("receivableGrid").getStore().load({params : {start : 0, limit : 15}});
								}
	   			},"-"],

		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : receivableStore,
		   columns: [
		             {header : '单位名称', dataIndex : 'ReceivableName',width:150},
		             {header : '应收账款', dataIndex : 'ReceivableRecei'},
		             {header : '发生时间', dataIndex : 'ReceivableDate', sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
		             {header : '款项内容', dataIndex : 'ReceivableContent'},
		             {header : '余额(人民币)', dataIndex : 'ReceivableRbalance', menuDisabled : true},
		             {header : '余额(美金)', dataIndex : 'ReceivableDbalance', menuDisabled : true},
		             {header : '业务员', dataIndex : 'ReceivableClerk'},
		             {header : '备注', dataIndex : 'ReceivableRemark', menuDisabled : true}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			   	   tmp = record.id;
				   Ext.getCmp("receivableForm").form.loadRecord(record);
				   Ext.getCmp("receivableForm").buttons[0].setText('修改');
			   }
		   
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return receivableGrid;
	},
	
	
	infoWin : function(){
  	  var infoWin = new Ext.Window({
  	  	id: 'receiInfo',
        title:'应收款查询',
        layout: 'fit',
        width:330,    
        height:250,
        modal: true,
        draggable : false,
        resizable: false,
        closeAction:"close",
        plain:true,    
        items:[receivables.queryForm()] 
        
    });  
  		return infoWin;
  	},
  	
  	queryForm : function(){
  		
  		
  	 var queryForm = new Ext.form.FormPanel({
			baseCls:"x-plain",
			frame : true,
			autoHeight : true,
			labelAlign : 'right',
			labelWidth : 85,
			defaultType : 'textfield',
				defaults : {
				width : 200
			},
			items : [{
					  fieldLabel: "单位名称",
      	    		  name: "receivable.name"
			 	  },{
					  fieldLabel: "业务员",
      	    		  name: "receivable.clerk"
			 	  },{
            		  xtype: 'datefield',
                      fieldLabel: "开始日期", //第三行，出生日期 
                      format : 'Y-m-d',
            		  name: "receivable.date"
				   },{
            		  xtype: 'datefield',
                      fieldLabel: "结束日期", //第三行，出生日期 
                      format : 'Y-m-d',
            		  name: 'receivable.endDate'
				   }],
			buttons:[{
        		 text:'确认',
             	 handler:function(){
             	 	var name = queryForm.form.findField('receivable.name').getValue()
             	 	var clerk = queryForm.form.findField('receivable.clerk').getValue()
             	 	var date = queryForm.form.findField('receivable.date').getValue();
             	 	var endDate = queryForm.form.findField('receivable.endDate').getValue();
				 Ext.getCmp("receivableGrid").getStore().baseParams = {'flag': true,'receivable.name':name,
					 													  'receivable.clerk':clerk,
					 													  'receivable.date':date,
					 													  'receivable.endDate':endDate,
					 													  'receivable.type': 'local'};
				 Ext.getCmp("receivableGrid").getStore().load({params : {start : 0, limit : 15}});
				 queryForm.form.reset();
                 Ext.getCmp("receiInfo").close();
              	
              	}
              },{
                 text:'取消',
                 handler:function(){
                 	queryForm.form.reset();
                 	Ext.getCmp("receiInfo").close();
                 }
              }]   
        });
        return queryForm;
  	
  	}
  }
}();








